def partition(li, left, right):
    tmp = li[left]
    while left < right:
        while left < right and li[right] >= tmp:  # 左边的下标小雨右边 & 右边的值大于tmp
            right -= 1  # 往左边挪
        li[left] = li[right]  # 把右边的值放左边

        while left < right and li[left] <= tmp:
            left += 1  # 往右边挪
        li[right] = li[left]  # 把左边的值往右边放

    li[left] = tmp
    return left


def quickly_sorted(li, left, right):
    if left < right:
        mid = partition(li, left, right)
        quickly_sorted(li, left, mid - 1)
        quickly_sorted(li, mid + 1, right)



# l = [3, 4, 1, 5, 9, 2, 7, 8, ]
l = [8,1,4,6,9,3,5,7 ]
quickly_sorted(l, 0, len(l) - 1)
print(l)


import getpass

api_key = getpass.getpass()